package cathe

import "fmt"

// 商品库存同步到redis
func SyncGoodsStock(goodsId, num int) {
	key := fmt.Sprintf("goods_num:%d", goodsId)
	for i := 0; i < num; i++ {
		Rdb.LPush(ctx, key, num)
	}
}

// 获取库存数量
func GetGoodsStock(goodsId int) (stock int64, err error) {
	key := fmt.Sprintf("goods_num:%d", goodsId)
	stock, err = Rdb.LLen(ctx, key).Result()
	return
}
